//
// @Auther: by wujehy 
// @Email:wujehy@qq.com
// @Data:2020/9/11
// @Time:4:29 下午
//
//

#ifndef GEEJOAN_BASECOMPONENT_H
#define GEEJOAN_BASECOMPONENT_H

#include <cstdio>
#include <string>
#include <functional>
#include <memory>
#include "NetworkProtocol.h"

namespace GeeJoan
{
//    class Connection;
    class BaseNetwork
    {
        friend class Connection;

        virtual int remove_client(int id) = 0;

    public:
        /**
         * @brief　服务端向客户端发送消息
         * @param hander 句柄
         * @param code 状态码
         * @param msg 内容主体
         * @param callback 发送状态回调
         * @return
         */
        virtual int sendMsg(std::unique_ptr<HanderDataType> hander, StatusCodeTypeEnum code, const std::string &msg = "", std::function<void(int status)> callback = nullptr) = 0;
    };

    class Global_Context;

    class BaseComponent
    {
    protected:
        Global_Context *globalContext = nullptr;
    public:
        /**
         * @brief 统一初始化 接口哦偶
         */
        virtual void init() = 0;

        /**
         * @brief 将上下文传递所有 成员
         * @param context
         */
        virtual void init_complete(Global_Context *context) = 0 ;

        virtual ~BaseComponent()
        {
            printf( "delete BaseComponentnt \n" );
        }

    };
}

#endif //GEEJOAN_BASECOMPONENT_H
